<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../assets/font/iconfont.css">
    <style>
        .iconfont{
            cursor: pointer;
        }
        .icon-collection-b{
            color: goldenrod;
            padding-right: 4px;
        }
        .icon-collection{
            color: #999;
            padding-right: 4px;
        }
    </style>
    <script src="../assets/js/vue.js"></script>
</head>
<body>
    
    <!-- <div id="aa" class="star-box">
        <span class="iconfont icon-collection-b"></span>
        <span class="iconfont icon-collection"></span>
        <span class="iconfont icon-collection"></span>
        <span class="iconfont icon-collection"></span>
        <span class="iconfont icon-collection"></span>
    </div> -->
    <hr>
    <div id="aa"></div>
    <hr>
    <div id="bb"></div>
    <hr>
    <script>

        let ItanyStar = Vue.extend({
            // template:`
            //     <div class="star-box">
            //         <span class="iconfont icon-collection-b"></span>
            //         <span class="iconfont icon-collection"></span>
            //         <span class="iconfont icon-collection"></span>
            //         <span class="iconfont icon-collection"></span>
            //         <span class="iconfont icon-collection"></span>
            //     </div>
            // `,
            template:`
                <div class="star-box" @mouseout=" source=0 ">
                    <span class="iconfont" 
                        v-for=" item in 5 " 
                        :class=" source>=item?'icon-collection-b':'icon-collection' "
                        @mouseover=" setSouce(item) "
                    ></span>
                    <span>{{ source }}</span>
                </div>
            `,
            data(){
                return {
                    source:0
                }
            },
            methods: {
                setSouce(nv){
                    this.source = nv;
                }
            },
        })
        
        new ItanyStar({
            el:"#aa",
            // template:`<h1>测试</h1>`
        })
        new ItanyStar({
            el:"#bb"
        })
    </script>
</body>
</html>